<template>
  <div>
    <Row style="padding-top: 16px;text-align: left" align="middle" type="flex" class="y_query_right">
      <Button type="primary" style="margin-left: 16px" icon="md-search" @click="search">查询</Button>
    </Row>

    <!--表格和分页-->
<!--    <Table stripe border ref="dailyStatisticFailList" :columns="dailyStatisticFailTable" :data="dailyStatisticFailList"
           class="table_css" no-data-text="暂无数据" ></Table>-->
    <List border class="data-list">
      <template v-if="dailyStatisticFailList.length == 0">
        <ListItem class="list-item">
          <div style="width: 100%; text-align: center; color: #ccc;">暂无数据</div>
        </ListItem>
      </template>
      <template v-else>
        <ListItem v-for="(item, index) in dailyStatisticFailList" :key="index" class="list-item">
          <div class="item-top">
            <KeyValueView title="统计类型" :value="getStatisticType(item)"></KeyValueView>
            <KeyValueView title="统计日期" :value="item.failDate"></KeyValueView>
          </div>
          <div class="item-bottom">
            <Button type="primary" size="small" @click="reStatistic(item.id)">重新统计</Button>
          </div>
        </ListItem>
      </template>
    </List>

    <div style="float: right; margin-top: 20px;">
      <Page :total="tPage.total" :page-size="tPage.stepNumber" :current="tPage.currentPage" @on-change="changePage"
            @on-page-size-change="sizeChange" :page-size-opts=[40,60,80,120]
            show-sizer show-elevator/>
    </div>

  </div>

</template>

<!--javascript 代码-->
<script>
    import ICol from "../../../node_modules/view-design/src/components/grid/col";
    import tiyData from "./js/dailyStatisticFail/dailyStatisticFail_data";
    import {
        init,
        searchService,
        reStatisticData
    } from "./js/dailyStatisticFail/dailyStatisticFail_funs";
    import KeyValueView from "../widgets/KeyValueView";

    export default {
        components: {KeyValueView, ICol},
        data(){
            return {
                tRole: {//权限
                },
                tParam : tiyData.tParams,
                tPage : tiyData.tPage,
                dailyStatisticFailList : tiyData.tData.dailyStatisticFailList,
                dailyStatisticFailTable :tiyData.dailyStatisticFailTable(this),
            }
        },
        computed: {
        },
        methods: {
            search(){
                tiyData.tPage.currentPage = 1;
                searchService(this,tiyData);
            },
            changePage(page){
                tiyData.tPage.currentPage = page;
                searchService(this, tiyData);
            },
            sizeChange(p){
                tiyData.tPage.stepNumber = p;
                searchService(this, tiyData);
            },
            reStatistic(id){ //重新统计此数据
                reStatisticData(this, tiyData, id);
            },
          getStatisticType(item) {
            if (item.statisticType == 1){
              return "用户数据";
            }else if(item.statisticType == 2) {
              return "产品数据";
            }else{
              return "";
            }
          },
        },
        created(){
            init(tiyData);
            // searchService(this,tiyData);
        }
    }
</script>

<!--css样式-->
<style scoped lang="less">
@import  (once,optional)  "../css/base.less";

  .table_css {
    margin-top: 20px;
    margin-bottom: 20px;
  }

  .tiy_key {
    color: #9e9e9e;
    min-width: 90px;
    display: inline-block;
    text-align: right;
    padding-right: 0.5rem;
  }
.data-list {
  margin: 1rem 0rem;
  line-height: 25px;
  .list-item {
    .flex-colum-wrap;
    justify-items: left;
    align-items: start;
    .item-checkbox {
      display: inline-block;
      width: 25px;
      height: 25px;
      text-align: center;
      vertical-align: top;
    }
    .item-img {
      width: 130px;
      text-align: center;
      display: inline-block;
    }
    .item-top{
      width: 100%;
      margin-bottom: 5px;
      .flex-row-wrap;
      justify-content: left;
    }
    .item-content {
      margin-bottom: 35px;
      text-align: left;
    }
    .item-bottom{
      //position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      display: block;
      //padding: 0 1rem 0.5rem 0;
      text-align: right;
      button {
        margin-left: 0.5rem;
      }
    }
  }
}
</style>
